define(['./../initial'], function() {
    var app = angular.module('App.home');
    app.factory('mapInstance', ['$rootScope',
        function($rootScope) {
            var oo = {
                getMap: function() {
                    return $rootScope.map;
                },
                setMap: function(map, state) {
                    $rootScope.map = map;
                    if (state) {
                        oo.setMapState(state);
                    }
                },
                setMapState: function(state) {
                    $rootScope.map.viewState = state;
                    $rootScope.$broadcast("mapViewSateChanged", state);
                },
                getMapState: function() {
                    return $rootScope.map.viewState;
                }
            };
            return oo;
        }
    ]);
});
